package fr.umlv.m2.jee.spij.persistence.schooling.dao;

import fr.umlv.m2.jee.spij.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.spij.persistence.schooling.ITrainingDAO;
import fr.umlv.m2.jee.spij.persistence.schooling.Training;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 *
 */
@Repository("hibernateTrainingDAO")
public class HibernateTrainingDAO extends AbstractHibernateDAO<Long, Training>
        implements ITrainingDAO {

    @Override
    public Training findByName(String name) {
        Session session = getHibernateSession();
        Criteria criteria = session.createCriteria(Training.class);
        criteria.add(Restrictions.like("name", name));
        return (Training) criteria.uniqueResult();
    }

}
